package com.shaobufan.museum.controllar;

import com.shaobufan.museum.common.BaseResponse;
import com.shaobufan.museum.common.ResultUtils;
import com.shaobufan.museum.pojo.entity.MuseumNotice;
import com.shaobufan.museum.pojo.entity.Notice;
import com.shaobufan.museum.pojo.request.notice.interior.NoticeAddRequest;
import com.shaobufan.museum.service.MuseumNoticeService;
import com.shaobufan.museum.service.NoticeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 公告请求
 */
@RestController
@RequestMapping("/internal")
public class InternalNoticeController {
    @Resource
    NoticeService noticeService;

    @ApiOperation("获取部门通知")
    @GetMapping("/get/{params}")
    public BaseResponse<List<Notice>> getNotice(@PathVariable Integer params) {
        List<Notice> noticeList = noticeService.searchNoticeByDepartId(params);
        return ResultUtils.success(noticeList, "部门通知");
    }

    @ApiOperation("添加通知")
    @PostMapping("/add")
    public BaseResponse<Boolean> setNotice(@RequestBody NoticeAddRequest noticeAddRequest) {
        Boolean added = noticeService.addNotice(noticeAddRequest);
        return ResultUtils.success(added, "添加成功");
    }
}